<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">    
    <h:head>
        <link rel="stylesheet" type="text/css" href="style.css" media="screen" />
        <title>Verium</title>
    </h:head>
    <c:choose>
        <c:when test="#{login.isLoggedin==true}">
            <h:body>        
                <h:form id="form">
                    <p:layout fullPage="true">                
                        <p:layoutUnit position="center" header="Batch" size="300">
                            <c:if test="#{productTable.selectedProduct!=null}">
                                <p:dataTable id="products" var="product" value="#{productTable.selectedProduct.batchTable.batches}" 
                                             selection="#{productTable.selectedProduct.batchTable.selectedBatch}" selectionMode="single" rows="9999999">
                                    <p:column filterBy="#{batch.name}">
                                        #{batch.name}
                                    </p:column>
                                </p:dataTable>
                            </c:if>
                        </p:layoutUnit>
                        <p:layoutUnit position="north" size="130">
                            <p:commandButton value="Logout" action="#{login.logout()}"/>                        
                        </p:layoutUnit>
                        <p:layoutUnit position="east" size="1300" >
                        </p:layoutUnit>
                        <p:layoutUnit position="west" size="300" header="Product" >
                            <h:form id="form">
                                <p:dataTable id="products" var="product" value="#{productTable.products}"
                                             selection="#{productTable.selectedProduct}" selectionMode="single" rows="9999999">
                                    <p:ajax event="rowSelect" update=":form"/>
                                    <p:column filterBy="#{product.name}">
                                        #{product.name}
                                    </p:column>
                                </p:dataTable>
                            </h:form> 
                        </p:layoutUnit>
                    </p:layout>        
                </h:form>
            </h:body>
        </c:when>
        <c:otherwise>
            <h:body onload='window.location.href = "/Verium"'/>
        </c:otherwise>
    </c:choose>        
</html>

